<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>内容页</title>
		<link rel="stylesheet" type="text/css" href="./Public/Home/css/index.css"/>
		<link rel="stylesheet" type="text/css" href="./Public/Home/css/content.css"/>
		<script src="Public/jquery-1.8.2.min.js" type="text/javascript" charset="utf-8"></script>
		<script>
			$(function () {
				$('.desk-one').click(function(){

					$(this).addClass('abcd').siblings().removeClass('abcd');
					//li标签的个数，也就是有多少属性
					var liLen=$('.two-quarter').length;
					//选中的元素个数
					var redLen=$('.abcd').length;
					if (redLen==liLen){
						var str='';
						//得到所有选中的商品属性ID，然后发异步
						$.each($('.radio-label'),function () {
							str +=$(this).attr('specId')+ ',';
						})

					}
				})
			})
		</script>
		<script>
			$(function(){
				$('.button-left').click(function(){
				var name=$('.product-title').html();
                var gid=$(this).attr('gid');
//                console.log(gid);
                var price=$('.price').text();
                var oldPrice=$('.old-price').text();
//                    console.log(price);
                var num=$('.number').val();
					var type=[];
					$.each($('.module'),function (k,v){
						var gname=$(this).find('.radio-label').text();
						var gvalue=$(this).find('.abcd').text();
						type.push(gname+':'+gvalue);
					})
					$.ajax({
						type:"post",
						url:"{{U('Cart/add')}}",
						data:{id:gid,name:name,num:num,price:price,oldPrice:oldPrice,options:type},
						dataType:"text",
						success:function (phpData) {
//                            location.href = ;
						}
					})
//                    return false;
				})
			})
		</script>
	</head>
	<body>

		<!--头部条开始-->
		{{include file="../Common/header"}}

	<!--导航区域结束-->
	
	<!--内容部分开始-->
	{{foreach from="$data" value="$v"}}

				<div id="main-content">
			<ul class="breadcrumb">

			</ul>
			<div class="buying-details">
				<div class="left-photo">
					<img src="{{$v['smallpic']}}" style="width: 588px;height: 665px;"/>
					<div class="owl-stage">
						<div class="ps-carousel">
							<div class="active">
								<img src="{{$v['smallpic']}}" style="width: 77px;height: 77px;border-radius: 50%;"/>
							</div>
						</div>
					</div>
				</div>
				<div class="">

				</div>
					<div class="right-details">
					<div class="buying-header-desk">
						<h1 class="product-title">
							{{$v['gname']}}
						</h1>
						<p class="product-name-extra">
							{{$v['intro']}}
						</p>
					</div>
					<div class="buying-price">
							<p>
								￥<strong class="price">{{$v['shopprice']}}</strong>
								{{if value="$v['marketprice']!=0"}}
								￥<span class="old-price">{{$v['marketprice']}}</span>
								{{endif}}
							</p>
					</div>
					<div class="add-cart">
						<form class="add-cart-form" action="{{U('Cart/index')}}" method="post">
							{{foreach from="$goodsAttrData" value="$v"}}
								<div class="module">
								<div class="one-quarter">
									<div class="radio-label" specId="{{$v['gaid']}}">
										{{$v['taname']}}
									</div>
								</div>
								<div class="two-quarter">
									{{foreach from="$v['value']" value="$value"}}
											<div class="desk-one">
											<a href="javascript:;">
												{{$value}}
											</a>
										</div>
									{{endforeach}}
								</div>
							</div>
							{{endforeach}}
							<div class="buying-action">
								<script>
									$(function(){
										$('.minus').click(function () {
											var num=parseInt($(".number").val())||0;
											num=num-1;
											num=num<1?1:num;
											$(".number").val(num);
										})
										$('.plus').click(function () {
											var num=parseInt($(".number").val())||0;
											$(".number").val(num+1);
										})
									})
								</script>
								<div class="lap-one">
									<div class="wrapper">
										<div class="counter-box">
											<a  href="javascript:;" class="minus" >-</a>
											<input type="text" value="1" class="number" />
											<a href="javascript:;" class="plus">+</a>
										</div>
									</div>
								</div>

								<div class="lap-two">
									<div class="one-half">
										<button class="button-left" gid="{{$_GET['gid']}}"><a href="{{U('Cart/index')}}">加入购物车</a></button>
									</div>
									<div class="two-half">
										<button class="button-right" gid="{{$_GET['gid']}}"><a href="{{U('Cart/index')}}">立即购买</a></button>
									</div>

								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
		{{endforeach}}

		<!--内容部分结束-->
				<div class="product-view">
			<div class="product-view-tabs">
				<ul class="wrapper">
					<li class="product">
						<a href="javascript:;">商品详情</a>
					</li>
					<li class="norms">
						<a href="javascript:;">规格参数</a>
					</li>
				</ul>
			</div>
			<div class="product-detail-tab">
				{{foreach from="$detailData" value="$v"}}
					<p class="photo1">
							<img src="{{$v}}" style="border: 0;vertical-align: middle;height: auto;"/>
					</p>
				{{endforeach}}
			</div>
		</div>







		{{include file="../Common/footer"}}
	</body>
</html>
